package com.verify.emun;

public enum ORG_TYPE {
    DEPARTMENT("部门", 8),
    WORK_AREA("作业区", 10),
    SECTION("科室", 10),
    TEAM("班组", 12),
    COMPANY("公司", 4);

    private final String name;
    private final int length;

    // 构造方法，用于初始化name属性
    ORG_TYPE(String name, int length) {
        this.name = name;
        this.length = length;
    }

    // 获取name属性的值
    public String getName() {
        return name;
    }

    public int getLength() {
        return length;
    }

    public static boolean containLength(ORG_TYPE type, int length) {
        return type.getLength() == length;
    }

    public static ORG_TYPE getByName(String name){
        for (ORG_TYPE type : ORG_TYPE.values()) {
            if (type.getName().equals(name)) {
                return type;
            }
        }
        return null;
    }

    // 静态方法：检查传入的字符串是否包含在枚举值中
    public static boolean contains(String value) {
        for (ORG_TYPE type : ORG_TYPE.values()) {
            if (type.getName().equals(value)) {
                return true;
            }
        }
        return false;
    }
}
